from django.urls import path,include
from course import views
from rest_framework.routers import DefaultRouter

# Viewsets 方法二(第一步)：
route = DefaultRouter()
route.register(prefix="viewsets",viewset=views.CourseViewSet)

urlpatterns = [
    #FBV
    path("fbv/list/",views.course_list,name='fbv-list'),
    path("fbv/detail/<int:pk>",views.course_detail,name='fbv-detail'),
    #CBV
    path("cbv/list/",views.CourseList.as_view(),name='cbv-list'),
    path("cbv/detail/<int:pk>",views.CourseDetail.as_view(),name='cbv-detail'),
    #GCBV
    path("gcbv/list/",views.GCourseList.as_view(),name='gcbv-list'),
    path("gcbv/detail/<int:pk>",views.GCourseDetail.as_view(),name='gcbv-detail'),
    # #ViewSets 方法一：
    # path("viewsets/",views.CourseViewSet.as_view(
    #     {"get":"list","post":"create"}
    # ),name='viewsets-list'),#{"请求名":"方法名"}
    # path("viewsets/<int:pk>",views.CourseViewSet.as_view(
    #     {"get":"retrieve","put":"update","patch":"partial_update","delete":"destroy"}
    # ),name='viewsets-detail'),

    # Viewsets 方法二（第二步）：
    path("",include(route.urls))
]